import request from '@/utils/request'
// import qs from 'qs'

// kafka数据上报

// kafka服务器日志外发开关
export function kafkaSwitch (params) {
  var data = fromData(params)
  return request({
    url: '/log/kafkaSwitch',
    method: 'post',
    data
  })
}

// 修改kafka服务器日志配置
export function setKafkaConfig (data) {
  return request({
    url: '/log/setKafkaConfig',
    method: 'post',
    data
  })
}

// 查看kafka日志配置
export function getKafkaLogConfig (params) {
  var data = fromData(params)
  return request({
    url: '/log/getKafkaLogConfig',
    method: 'post',
    data
  })
}

// 清空kafka日志配置
export function cleanKafkaLogConfig (params) {
  var data = fromData(params)
  return request({
    url: '/log/cleanKafkaLogConfig',
    method: 'post',
    data
  })
}

function fromData (params) {
  let formData = new FormData()
  for (const it in params) {
    if (!Object.is(params[it], null) && !Object.is(params[it], '')) {
      formData.append(it, params[it])
    }
  }
  return formData
}
